package com.softaria.windows.model;

import java.io.Serializable;

/**
 * Sets size of Frame to some percentage of size of its parent panel
 * 
 * @author Roman M Kuzmin (roman@softaria.com)
 * 
 */

public class FloatSizeCalculator implements SizeCalculator, Serializable {

  private static final long serialVersionUID = 1L;
  private float widthFloat;
  private float heightFloat;

  public FloatSizeCalculator(float widthFloat, float heightFloat) {
    super();
    this.widthFloat = widthFloat;
    this.heightFloat = heightFloat;
  }

  protected FloatSizeCalculator() {

  }

  public FloatSizeCalculator(double w, double h) {
    this((float) w, (float) h);
  }

  public Size calculateSize(final int offsetWidth, final int offsetHeight) {
    return new Size() {

      public int getHeight() {
        return (int) (offsetHeight * heightFloat);
      }

      public int getWidth() {
        return (int) (offsetWidth * widthFloat);
      }

    };
  }

  public float getWidthFloat() {
    return widthFloat;
  }

  public float getHeightFloat() {
    return heightFloat;
  }

}
